﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Configuration;

using Core.DAL;

namespace Core.Utils
{
    public class GeneralUtils
    {
        public  static ScoutNetDataContext GetDataContext()
        {
            if (HttpContext.Current != null)
            {
                if (HttpContext.Current.Items["DBDataContext"] == null)
                {
                    HttpContext.Current.Items["DBDataContext"] = new ScoutNetDataContext(ConfigurationManager.ConnectionStrings["ScoutNetConnectionString"].ConnectionString);
                }

                return (ScoutNetDataContext)HttpContext.Current.Items["DBDataContext"];
            }
            else
            {
                return new ScoutNetDataContext(ConfigurationManager.ConnectionStrings["ScoutNetConnectionString"].ConnectionString);
            }
        }
    }
}
